package com.ruoyi.contact.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.contact.domain.ContactReminder;
import com.ruoyi.contact.service.IContactReminderService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 联系人提醒Controller
 * 
 * @author useragent-1
 * @date 2025-06-04
 */
@Controller
@RequestMapping("/contact/reminder")
public class ContactReminderController extends BaseController
{
    private String prefix = "contact/reminder";

    @Autowired
    private IContactReminderService contactReminderService;

    @RequiresPermissions("contact:reminder:view")
    @GetMapping()
    public String reminder()
    {
        return prefix + "/reminder";
    }

    /**
     * 查询联系人提醒列表
     */
    @RequiresPermissions("contact:reminder:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ContactReminder contactReminder)
    {
        startPage();
        List<ContactReminder> list = contactReminderService.selectContactReminderList(contactReminder);
        return getDataTable(list);
    }

    /**
     * 导出联系人提醒列表
     */
    @RequiresPermissions("contact:reminder:export")
    @Log(title = "联系人提醒", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ContactReminder contactReminder)
    {
        List<ContactReminder> list = contactReminderService.selectContactReminderList(contactReminder);
        ExcelUtil<ContactReminder> util = new ExcelUtil<ContactReminder>(ContactReminder.class);
        return util.exportExcel(list, "联系人提醒数据");
    }

    /**
     * 新增联系人提醒
     */
    @RequiresPermissions("contact:reminder:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存联系人提醒
     */
    @RequiresPermissions("contact:reminder:add")
    @Log(title = "联系人提醒", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ContactReminder contactReminder)
    {
        return toAjax(contactReminderService.insertContactReminder(contactReminder));
    }

    /**
     * 修改联系人提醒
     */
    @RequiresPermissions("contact:reminder:edit")
    @GetMapping("/edit/{reminderId}")
    public String edit(@PathVariable("reminderId") Long reminderId, ModelMap mmap)
    {
        ContactReminder contactReminder = contactReminderService.selectContactReminderByReminderId(reminderId);
        mmap.put("contactReminder", contactReminder);
        return prefix + "/edit";
    }

    /**
     * 修改保存联系人提醒
     */
    @RequiresPermissions("contact:reminder:edit")
    @Log(title = "联系人提醒", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ContactReminder contactReminder)
    {
        return toAjax(contactReminderService.updateContactReminder(contactReminder));
    }

    /**
     * 删除联系人提醒
     */
    @RequiresPermissions("contact:reminder:remove")
    @Log(title = "联系人提醒", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(contactReminderService.deleteContactReminderByReminderIds(ids));
    }
}
